Content addressable memory (CAM) devices enjoy a variety of applications due to their fast matching capability. As an example, Network Search Engines (NSEs) often use CAM devices to provide fast searches of a database, list, and/or pattern, such as in computers and communication networks. A CAM can simultaneously compare a specific pattern of bits, commonly known as a search key or comparand, against a large number of bit patterns stored in an associated CAM memory array. In this way, an entire CAM array can be searched in parallel,
A CAM array may optionally have a mask value for each entry that indicates which bit location(s) in an entry to match, and hence which bits to exclude from a compare/search operation. If there is a match for every non-masked bit in a location (e.g., entry) with every corresponding bit of a comparand, a match flag can be asserted to let the user know that the comparand data was found in the CAM. In addition, a value corresponding to the matching location can be returned. Thus, in a CAM device a result can be determined from finding a matching value (content), not from providing the address for value, as is done for a Random Access Memory (RAM).
In some devices or systems, if no matching entries are found, a learn instruction can subsequently be executed. A learn instruction can instruct a CAM device to write comparand data used in a search. that resulted in a miss, into a next available empty location in the CAM array.
A conventional circuit and process of implementing a learn function or operation is shown in FIGS. 5A to 5C. A conventional circuit 500 can include a data field 502-0 and mask field 502-1. In addition, a conventional CAM circuit can include an internal comparand register 504 as a source of data for a learn operation. Data field 502-0 can include an available entry (represented by Data=???), while mask field 502-1 can include a mask for the available entry (represented by Mask=???).
Referring now to FIG. 5A, prior to a search operation, an internal comparand register 504 can be empty or store data from a previous operation that is not used (represented by Reg=???).
As shown in FIG. 5B, after a search operation has been executed and completed, comparand data from the search (Data1) can be stored in internal comparand register 504 (represented by Reg=Data1).
FIG. 5C shows the execution of a subsequent learn operation. Such an operation can occur whether or not the previous search operation resulted in no matching entries. When a learn operation is executed, comparand data (Data1) previously stored in internal comparand register 504 can be used as write data to be loaded data in to the internal CAM memory array.
A problem with the above conventional approach can be that when the learn instruction is executed, only the contents of internal register 504 are used for the write data. As shown in FIG. 5C, a learn instruction can result in a write to either a data field 502-0 or mask field 502-1 in the CAM memory array. Unfortunately, since there is only one internal register with a value inside, the same value gets written into either the mask or data field or to both. This can represent a limitation or failure of the conventional learn operation, as this is generally not what a user wants or intends.
In a learn operation, the user usually wants to store a <mask, data> pair into a free entry of a CAM memory array where the mask and data values could be different. Since a search operation only uses the data portion as the search key, the internal comparand register 504 will contain only the data portion, and the mask field cannot be updated with a unique or different value.
There have been several attempts to overcome or work around the above problem. Generally, such conventional approaches involve convoluted and costly solutions that are not wholly satisfactory. For example, a conventional approach can execute a learn operation to write data into a data field, as desired. Then, a number of extra read operations are performed to try and determine the address of the entry to which the data has been written. Once the address has been located, a unique mask value can be written into the corresponding location within the mask field.
Accordingly, it would be desirable to arrive at some way of updating both the mask field and the data field using a learn operation.